package com.blockmeta.bbs.baselibrary.utils;

import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.widget.TextView;

import java.util.List;

/**
 * Created by author on 2018/1/2.
 */

public class SimpleTextWatcher implements TextWatcher {
    private static boolean noEmpty;

    private List<TextView> tvs;

    public TvCallBack tvCallBack;

    public SimpleTextWatcher(List<TextView> tvs) {
        this.tvs = tvs;
    }

    public void setNoEmpty(TvCallBack tvCallBack) {
        this.tvCallBack = tvCallBack;
    }

    @Override
    public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

    }

    @Override
    public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

    }

    @Override
    public void afterTextChanged(Editable editable) {
//        for (int i = 0; i < list.size(); i++) {
//            if (!TextUtils.isEmpty(list.get(i).getText().toString().trim())){
//                noEmpty = true;
//            }else {
//                noEmpty = false;
//            }
//        }
//        isEmpty();
        for (int i = 0; i < tvs.size(); i++) {
            if (!TextUtils.isEmpty(tvs.get(i).getText().toString().trim())) {
//               tvCallBack.noEmpty();
                noEmpty = true;
            } else {
                noEmpty = false;
            }
            if (noEmpty) {
                tvCallBack.noEmpty();
            } else {
                tvCallBack.withEmpty();
            }
        }

    }



    public interface TvCallBack {
        void withEmpty();

        void noEmpty();
    }
}
